package pl.puntin.punclient.messages;

public class UpdateRankingMessage extends Message {

	public String[] names;
	public String[] points;
	
	
	@Override
	public byte getType() {
		return MessageTypes.S_UPDATE_RANKING;
	}
	
	@Override
	protected void yourDataIsReadyInitYourSelf(final byte[] data)
	{
		int textLenght = 1;
		for (; textLenght < data.length; textLenght++)
		{
			if(data[textLenght] == 0)
				break;
		}
		
		String dataString = new String(data, 1, textLenght);
		
		String[] tmp = dataString.split("#");
		names = new String[tmp.length/2];
		points = new String[tmp.length/2];
		
		int i = 0;
		for(; i < (tmp.length-1); ++i)
		{			
			if((i%2) == 0)
				names[i/2] = tmp[i];
			else
				points[i/2] = tmp[i];
		}
	}
}
